{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from bs4 import BeautifulSoup\n",
    "from urllib.parse import quote\n",
    "import requests,time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "query = '国家电网公司'\n",
    "url = 'https://www.baidu.com/s?wd=' + quote(query)\n",
    "headers = {'User-Agent': 'Mozilla/5.0 (X11; U; Linux i686)Gecko/20071127 Firefox/2.0.0.11'}\n",
    "soup_baidu = BeautifulSoup(requests.get(url=url, headers=headers).content.decode('utf-8'), \"lxml\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "None\n"
     ]
    }
   ],
   "source": [
    "results = soup_baidu.find(id=2)\n",
    "print(results)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "base init:1\n",
      "medium init:1\n"
     ]
    }
   ],
   "source": [
    "class Base(object):\n",
    "    def __init__(self):\n",
    "        self.data = 1\n",
    "        print(\"base init:{}\".format(self.data))\n",
    "    def get_data(self):\n",
    "        return self.data\n",
    "\n",
    "class Medium(Base):\n",
    "    def __init__(self):\n",
    "        super(Medium,self).__init__()\n",
    "        self.data = super(Medium,self).get_data()\n",
    "        print(\"medium init:{}\".format(self.data))\n",
    "    \n",
    "a = Medium()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<!DOCTYPE html>\n",
      "<html lang=\"en\"><head>\n",
      "  <meta charset=\"utf-8\"/>\n",
      "  <meta content=\"width=device-width, initial-scale=1\" name=\"viewport\"/>\n",
      "  <meta content=\"能源语义 能源语义搜索 能源语义搜索引擎 电力 电网 科技文献 电网咨询新闻 自然语言处理 人工智能 语义检索\" http-equiv=\"keywords\" name=\"keywords\"/>\n",
      "  <title>能源语义搜索</title>\n",
      "<link href=\"./main.5d79bb6b.css\" rel=\"stylesheet\"/></head>\n",
      "<body>\n",
      "  <div id=\"root\"></div>\n",
      "<script src=\"./main.ae0a31c3.js\" type=\"text/javascript\"></script>\n",
      "\n",
      "</body></html>\n"
     ]
    }
   ],
   "source": [
    "import requests\n",
    "from bs4 import BeautifulSoup\n",
    "url = \"https://rises.tech/api/search?_kw=毛伟明&_page=0&_size=10\"\n",
    "res = requests.get(url)\n",
    "res.encoding = 'utf-8'\n",
    "soup = BeautifulSoup(res.text,\"html5lib\")\n",
    "print(soup)\n",
    "# tt=soup.body.find_all('ul',class_= 't clearfix')\n",
    "# tt2 = tt.find_all('li')\n",
    "# print(tt2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.7.1 64-bit ('base': conda)",
   "language": "python",
   "name": "python37164bitbasecondaa54b7275860a43afa9ef63830ac905b7"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
